package com.luodea.rabbitmqconsume;

import com.luodea.common.RabbitMqConfig;
import com.luodea.common.User;
import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.support.AmqpMessageHeaderAccessor;
import org.springframework.messaging.handler.annotation.Payload;
import org.springframework.stereotype.Component;

import java.io.IOException;


/**
 * ackMode = "manual" 开启确认消费模式
 */
@RabbitListener(queues = RabbitMqConfig.DIRECT_QUEUE_1)
@Component
public class HaConsume {


    @RabbitHandler
    public void handle(@Payload User user, AmqpMessageHeaderAccessor messageHeaderAccessor, Channel channel) throws IOException {

        System.out.println("消费高可用队列"+user.toString());
    }

}
